package cn.lovelysia.ymcc.web.controller;

import cn.lovelysia.ymcc.dto.SendSmsParamDto;
import cn.lovelysia.ymcc.result.JSONResult;
import cn.lovelysia.ymcc.service.IVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Map;

/**
 * 验证码接口类
 */
@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService;

    @GetMapping("/imageCode/{key}")
    public String getImageCode(@PathVariable("key") String key){
        return verifyCodeService.getImageCode(key);
    }

    /**
     * 接口：发送手机短信验证码
     * @param sendSmsParamDto
     * @return
     */
    @PostMapping("/sendSmsCode")
    public JSONResult getSmsCode(@RequestBody @Valid SendSmsParamDto sendSmsParamDto){
        verifyCodeService.getSmsCode(sendSmsParamDto);
        return new JSONResult();
    }
}
